Ext.define('PJ.view.celabankmanagement.QuestionsEdit', {
    extend: 'AM.default.DefaultWindowForm',
    requires: ['AM.default.jsonp.DefaultLoadJsonp',
               'AM.default.jsonp.DefaultSubmitJsonp'],
    
    title: '新增试题',
    layout: "fit",
    width: 500,
    //atuoHeight: true,
    height: 550,
    notEdit: true,
    selectData: null,
    fromPaper: false,
    overflowX: 'hidden',
    overflowY: 'scroll',
    initComponent: function(){
        var bt = "<span style='color:red;'>*</span>";
        var me = this;
        var tc = "options";
        var fz = "fzOptions"
        this.items = [{
            xtype: "container",
            anchor: "90%",
            margin: "15 0 10 0",
            layout: "column",
            defaults: {
                labelWidth: 80,
                labelAlign: "right",
                columnWidth: 1,
                padding: 5
            },
            items: [{
                fieldLabel: bt + "试题题型",
                name: "questionType",
                xtype: "combo",
                columnWidth: .5,
                valueField: "value",
                displayField: "text",
                editable: false,
                queryMode: 'local', //'remote',
                value: "danxt",
                allowBlank: false,
                store: Ext.create("Ext.data.ArrayStore", {
                    singleton: true,
                    fields: [{
                        name: 'value',
                        mapping: "dataCode",
                        type: 'string'
                    }, {
                        name: 'text',
                        mapping: "dataName",
                        type: 'string'
                    }],
                    proxy: {
                        type: gj_onlineLearning_constant.loadType == "jsonp" ? gj_onlineLearning_constant.loadType:'ajax',
                        url : me.grid.getStore().typeUrl,
                        reader: Ext.create('Ext.data.reader.Json', {
                            type: 'json',
                            root: 'data',
                            successProperty: 'success'
                        })
                    },
                    autoLoad: true
                }),
                listeners: {
                    change: function(f, n, o){
                        me.itemTypeChange(n);
                    }
                }
            }, {
                fieldLabel: bt + "试题题组",
                name: "questionsProblemSets",
                xtype: "combo",
                columnWidth: .5,
                valueField: "value",
                displayField: "text",
                editable: false,
                queryMode: 'local', //'remote',
                value: "1",
                allowBlank: false,
                store: Ext.create("Ext.data.ArrayStore", {
                    fields: ['value', 'text'],
                    data: [['1', '培训设计'], ['2', '培训实施'], ['3', '培训管理'], ['4', '培训效果'], ['5', '意见建议']]
                }),
                listeners: {
                    change: function(f, n, o){
                        //me.itemTypeChange(n);
                    }
                }
            }, {
                fieldLabel: bt + "试题题干",
                name: 'questionName',
                xtype: 'textareafield',
                allowBlank: false,
                rows: 6,
                maxLength: 120,
                maxLengthText: "题干最多可以输入120个中文字符或240个英文字符。",
                listeners: {
                    blur: function(){
                        this.setValue(this.getValue().trim());
                    }
                }
            }, {
                fieldLabel: " ",
                labelWidth: 80,
                xtype: "radiogroup",
                allowBlank: true,
                blankText: " ",
                labelSeparator: "",
                margin: "5 5 0 5",
                hidden: me.questionTypeFlag,
                isLimitModel: false,
                items: [{
                    name: "isLimitNum",
                    boxLabel: "单选数值型",
                    inputValue: "1",
                    checked: true,
                    itemId: "dxszx"
                }, {
                    name: "isLimitNum",
                    boxLabel: "文字型",
                    inputValue: "2",
                    itemId: "wzx"
                    //checked: true
                }],
                listeners: {
                    change: function(f, n, o){
                        /*
                        var form = this.up("form");
                            var wordNum = Ext.getCmp("wordNum1");
                            var wordNum2 = Ext.getCmp("wordNum2");
                            if (n.isLimitNum == 1) {
                            	wordNum.allowBlank = false;
                            	wordNum.setFieldLabel('<span style="color:red;">*</span>字数限制：字数上限为');
                            	wordNum.setDisabled(false);
                            	wordNum2.setDisabled(false);
                            }
                            else 
                                if (n.isLimitNum == 2) {
                                	wordNum.allowBlank = true;
                                	wordNum.setFieldLabel('字数限制：字数上限为');
                                	wordNum.setDisabled(true);
                                	wordNum2.setDisabled(true);
                                }
                                */
                    },
                    afterrender: function(){
                        //this.hide();
                    }
                }
            }, {
                fieldLabel: bt + "分值",
                xtype: "fieldcontainer",
                itemId: "fzID",
                id: "fzID",
                hidden: false,
                layout: "column",
                margin: "5 5 0 5",
                defaults: {
                    xtype: "combo",
                    store: Ext.create("Ext.data.ArrayStore", {
                        fields: ['value', 'text'],
                        data: [['1', '1分'], ['2', '2分'], ['3', '3分'], ['4', '4分'], ['5', '5分']]
                    }),
                    valueField: 'value',
                    displayField: 'text',
                    editable: false,
                    emptyText: "请选择",
                    labelWidth: 15,
                    margin: "5 0",
                    columnWidth: 1,
                    listeners: {
                        blur: function(item){
                            if (!Ext.isEmpty(item.getValue()) && item.tid) {
                                item.allowBlank = false;
                                if (item.tid < 5) {
                                    var nxt = this.up("fieldcontainer").down("#" + fz + (Number(item.tid) + 1)).enable();
                                    nxt.allowBlank = true;
                                }
                                if (item.tid < 6) {
                                    //this.up("form").down("#ans" + item.tid).enable();
                                }
                            }
                        }
                    }
                },
                items: [{
                    name: tc,
                    fieldLabel: "A",
                    margin: "0 0 5 0",
                    itemId: fz + "0",
                    id: fz + "0",
                    tid: "0",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    allowBlank: true
                }, {
                    name: tc,
                    fieldLabel: "B",
                    itemId: fz + "1",
                    tid: "1",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    name: tc,
                    fieldLabel: "C",
                    itemId: fz + "2",
                    tid: "2",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    name: tc,
                    fieldLabel: "D",
                    itemId: fz + "3",
                    tid: "3",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }/*, {
                    name: tc,
                    fieldLabel: "E",
                    itemId: fz + "4",
                    tid: "4",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }*/]
            },{
            	xtype: 'button',
                text: '保存',
                columnWidth: .4,
                margin: '0 5 0 85',
                itemId: 'baoc_1',
                id: 'baoc_1',
                handler: function(button, event){
                    
                }
            },{
            	xtype: 'button',
                text: '添加选项',
                columnWidth: .2,
                margin: '0 5 0 5',
                itemId: 'tjxx1',
                id: 'tjxx1',
                handler: function(button, event){
                    
                }
            },{
            	xtype: 'button',
                text: '重置',
                columnWidth: .2,
                margin: '0 5 0 5',
                itemId: 'chongz1',
                id: 'chongz1',
                handler: function(button, event){
                    
                }
            },{
            	xtype: 'button',
                text: '关闭',
                columnWidth: .2,
                margin: '0 5 0 5',
                itemId: 'guanb1',
                id: 'guanb1',
                handler: function(button, event){
                    
                }
            }, {
                fieldLabel: bt + "选项",
                xtype: "fieldcontainer",
                itemId: "tcID",
                id: "tcID",
                hidden:false,
                layout: "column",
                margin: "5 5 0 5",
                defaults: {
                    xtype: "textfield",
                    labelWidth: 15,
                    margin: "5 0",
                    columnWidth: .5,
                    listeners: {
                        blur: function(item){
                            var option = this.up("fieldcontainer").down("#" + tc + (Number(item.tid)));
                            option.setValue(option.getValue().trim());
                            if (!Ext.isEmpty(item.getValue()) && item.tid) {
                                item.allowBlank = false;
                                if (item.tid < 9) {
                                    var nxt = this.up("fieldcontainer").down("#" + tc + (Number(item.tid) + 1)).enable();
                                    nxt.allowBlank = true;
                                }
                                if (item.tid < 10) {
                                    //this.up("form").down("#ans" + item.tid).enable();
                                }
                            }
                        }
                    }
                },
                items: [{
                    name: tc,
                    fieldLabel: "A",
                    margin: "0 0 5 0",
                    itemId: tc + "0",
                    id: tc + "0",
                    tid: "0",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    allowBlank: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "B",
                    itemId: tc + "1",
                    tid: "1",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "C",
                    itemId: tc + "2",
                    tid: "2",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "D",
                    itemId: tc + "3",
                    tid: "3",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }/*, {
                    name: tc,
                    fieldLabel: "E",
                    itemId: tc + "4",
                    tid: "4",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "F",
                    itemId: tc + "5",
                    tid: "5",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "G",
                    itemId: tc + "6",
                    tid: "6",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "H",
                    itemId: tc + "7",
                    tid: "7",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "I",
                    itemId: tc + "8",
                    tid: "8",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }, {
                    name: tc,
                    fieldLabel: "J",
                    itemId: tc + "9",
                    tid: "9",
                    maxLength: 500,
                    maxLengthText: "该选项最多可以输入250个中文字符或500个英文字符。",
                    disabled: true
                }, {
                    fieldLabel: "是否为主观题",
                    labelWidth: 80,
                    xtype: "radiogroup",
                    allowBlank: true,
                    blankText: " ",
                    //labelSeparator: "",
                    margin: "5 5 0 5",
                    hidden: me.questionTypeFlag,
                    isLimitModel: false,
                    items: [{
                        name: "isSubjectiveQuestions",
                        boxLabel: "是",
                        inputValue: "1"
                        //itemId: "isLimitNum0"
                    }, {
                        name: "isSubjectiveQuestions",
                        boxLabel: "否",
                        inputValue: "2",
                        //itemId: "isLimitNum1",
                        checked: true
                    }]
                }*/]
            },{
            	xtype: 'button',
                text: '保存',
                columnWidth: .4,
                margin: '0 5 0 85',
                itemId: 'baoc_',
                id: 'baoc_',
                handler: function(button, event){
                    
                }
            },{
            	xtype: 'button',
                text: '添加选项',
                columnWidth: .2,
                margin: '0 5 0 5',
                itemId: 'tjxx',
                id: 'tjxx',
                handler: function(button, event){
                    
                }
            },{
            	xtype: 'button',
                text: '重置',
                columnWidth: .2,
                margin: '0 5 0 5',
                itemId: 'chongz',
                id: 'chongz',
                handler: function(button, event){
                    
                }
            },{
            	xtype: 'button',
                text: '关闭',
                columnWidth: .2,
                margin: '0 5 0 5',
                itemId: 'guanb',
                id: 'guanb',
                handler: function(button, event){
                    
                }
            }, {
                fieldLabel: "是否限制答案字数",
                labelWidth: 125,
                xtype: "radiogroup",
                itemId: "isLimitNum",
                allowBlank: true,
                blankText: "参考答案不允许为空！",
                margin: "5 5 0 5",
                hidden: me.questionTypeFlag,
                isLimitModel: false,
                items: [{
                    name: "isLimitNum",
                    boxLabel: "是",
                    inputValue: "1",
                    itemId: "isLimitNum0"
                }, {
                    name: "isLimitNum",
                    boxLabel: "否",
                    inputValue: "2",
                    itemId: "isLimitNum1",
                    checked: true
                }],
                listeners: {
                    change: function(f, n, o){
                        
                        var form = this.up("form");
                            var wordNum = Ext.getCmp("wordNum1");
                            var wordNum2 = Ext.getCmp("wordNum2");
                            if (n.isLimitNum == 1) {
                            	wordNum.allowBlank = false;
                            	wordNum.setFieldLabel('<span style="color:red;">*</span>字数限制：字数上限为');
                            	wordNum.setDisabled(false);
                            	wordNum2.setDisabled(false);
                            }
                            else 
                                if (n.isLimitNum == 2) {
                                	wordNum.allowBlank = true;
                                	wordNum.setFieldLabel('字数限制：字数上限为');
                                	wordNum.setDisabled(true);
                                	wordNum2.setDisabled(true);
                                }
                    },
                    afterrender: function(){
                        this.hide();
                    }
                }
            }, {
				xtype: "numberfield",
				fieldLabel: '字数限制：字数上限为',
				labelSeparator: "",
				name: "wordNum",
				itemId: "wordNum1",
				id: "wordNum1",
				allowDecimals: false,
				hideTrigger: true,
				allowBlank: false,
				hidden: me.questionTypeFlag,
                blankText: "字数限制不允许为空！",
                labelWidth: 135,
                columnWidth: .5,
                margin: "5 5 0 5",
                listeners: {
                    afterrender: function(){
                    	this.setDisabled(true);
                        this.hide();
                    }
                }
			}, {
				xtype: "label",
				text: "个汉字",
				itemId: "wordNum2",
				id: "wordNum2",
				columnWidth: .2,
				hidden: me.questionTypeFlag,
				margin: "5 0 0 5",
                listeners: {
                    afterrender: function(){
                    	this.setDisabled(true);
                        this.hide();
                    }
                }
			}, {
                xtype: "hidden",
                name: "questionId"
            },{
            	xtype:"hidden",
            	name:"questionnaireId",
            	value:me.questionnaireId
            }]
        }];
        
        this.buttons = [{
            text: '确定',
            handler: function(button, event){
                var win = button.up('window');
                var form = win.down('form');
				var baseForm = form.getForm();
                var optionArray = new Array();
                for (var i = 0; i < 9; i++) {
                    if (win.down("#tcID").down("#options" + i).value != null && win.down("#tcID").down("#options" + i).value != "") {
                        optionArray.push(win.down("#tcID").down("#options" + i).value);
                    }
                }
                for (var i = 0; i < optionArray.length - 1; i++) {
                    for (var j = 1; j < optionArray.length; j++) {
                        if (optionArray[i] == optionArray[j] && i != j) {
                            Ext.Msg.alert('警告', '此题包含重复选项！');
                            return;
                        }
                    }
                }
                win.sub();
            }
        }, {
            text: '关闭',
            handler: function(button, event){
                var win = button.up('window');
                win.close();
            }
        }];
        
        this.callParent(arguments);
    },
    
    listeners: {
        render: function(){
            this.show();
        },
        beforerender: function(){
            var me = this;
            if (!me.notEdit) {
            	var actionName = "load";//默认使用非JSONP的加载方法名“load”
                if(gj_onlineLearning_constant.loadType=="jsonp") {//根据模块的全局变量设置是否使用JSONP的方式请求数据
                	actionName= "loadJsonp";
                }
                me.down('form').getForm().doAction(actionName,{//使用doAction(action,{options})；方式加载数据
                    url: me.grid.getStore().perUpdateUrl,
                    params: {
                    	questionId:me.questionId
                    },
                    success:function(form,action){
                    	var selectData = action.result.data;//Ext.decode(action.response.responseText).data;
                        me.pushData(selectData);
                    }
                });
            };
        },
        afterrender: function(){
            this.itemTypeChange(this.resourceItemType);
        },
        afterlayout:function(){
        	//【IE8】输入A项后，点击B项的输入框没有反应，点击边上空白地方输入框才能打开
        	if(Ext.isIE8){
            	$("#tcID").find("input:disabled").attr("unselectable","");
            }
        }
    },
    
    sub: function(){
        var win = this;
        var form = win.down('form');
        var baseForm = form.getForm();
        if (!baseForm.isValid()) {
            return;
        }
        var url = "";
        if (this.notEdit) {
            url = win.grid.getStore().addUrl;
        }
        else {
            url = win.grid.getStore().updateUrl;
        }
        if(gj_onlineLearning_constant.loadType=="jsonp"){
        	form.getForm().doAction('submitJsonp',{
        		url: url,
        		params: {},
        		success: function(f, action){
        			if (action.result.success) {
        				Ext.Msg.alert('消息', "操作成功", function(){
        					win.close();
        					win.grid.getStore().reload();
        				});
        			}
        		},
        		failure: function(f, action){
        			if (action.result) {
        				Ext.Msg.alert('错误', action.result.msg, function(){
        				});
        			}else {
        				Ext.Msg.alert('错误', "操作失败", function(){
        				});
        			}
        		}
        	});
        }else if(gj_onlineLearning_constant.loadType=="ajax"){
        	win.submit({
                url: url,
                success: function(f, action){
                    if (action.result.success) {
                        Ext.Msg.alert('消息', action.result.msg, function(){
                            win.close();
                            win.grid.getStore().reload();
                        });
                    }
                },
                failure: function(f, action){
                    if (action.result) {
                        Ext.Msg.alert('错误', action.result.msg);
                    }
                    else {
                        Ext.Msg.alert('错误', "操作失败");
                    }
                }
            });
        }
    },
    /**
     * 根据试题类型显示相应控件
     * @param {string} code 控件类型编码
     */
    itemTypeChange: function(code){
		var win = this;
        if (!code) {
            code = "danxt";
        }
        var form = this.down("form");
        var _c = form.down("#tcID");
        var _f = form.down("#fzID");
        var _m = form.down("checkboxgroup");
        //var multiAnswer = form.down("#multiAnswer");
        var wordNum = form.down("#wordNum1");
        var isLimitNum = form.down("#isLimitNum");
        var wordNum2 = form.down("#wordNum2");
        
        var dxszx = form.down("#dxszx");//单选数字型
        var wzx = form.down("#wzx");//文字型
        var baoc_ = form.down("#baoc_");//保存-多
        var tjxx = form.down("#tjxx");//添加选项-多
        var chongz = form.down("#chongz");//重置-多
        var guanb = form.down("#guanb");//关闭-多
        var baoc_1 = form.down("#baoc_1");//保存-单
        var tjxx1 = form.down("#tjxx1");//添加选项-单
        var chongz1 = form.down("#chongz1");//重置-单
        var guanb1 = form.down("#guanb1");//关闭-单
        if (code == "danxt") {//单选
        	if(wordNum){
        		wordNum.allowBlank = true;
        		wordNum.hide();
        	}
        	if(isLimitNum){
        		isLimitNum.hide();
        	}
        	if(wordNum2){
        		wordNum2.hide();
        	}
//            _c.hide();
            _c.show();
            _f.show();
            //multiAnswer.show();
            _m.reset();
            _m.singleModel = false;
            //this.selectModel();
            this.clearTemContent();
            Ext.each(_c.items.items, function(item){
                item.reset();
            });
			win.setHeight(400);
			//Ext.getCmp("multiAnswer").allowBlank = false;
			//选项A
    		Ext.getCmp("options0").allowBlank = true;
    		Ext.getCmp("options0").setDisabled(true);
    		Ext.getCmp("fzOptions0").allowBlank = false;//分值A
    		baoc_1.show();
            tjxx1.show();
            chongz1.show();
            guanb1.show();
            dxszx.show();
        	wzx.show();
        }
        else if (code == "duoxt") {//多选
        	if(wordNum){
        		wordNum.allowBlank = true;
        		wordNum.hide();
        	}
        	if(isLimitNum){
        		isLimitNum.hide();
        	}
        	if(wordNum2){
        		wordNum2.hide();
        	}
        	_c.show();
            _f.hide();
        	//multiAnswer.show();
        	_m.reset();
        	_m.singleModel = true;
        	//this.selectModel();
        	this.clearTemContent();
        	Ext.each(_c.items.items, function(item){
        		item.reset();
        	});
        	win.setHeight(410);
        	//Ext.getCmp("multiAnswer").allowBlank = false;
    		//选项A
        	Ext.getCmp("options0").allowBlank = false;
    		Ext.getCmp("options0").setDisabled(false);
    		Ext.getCmp("fzOptions0").allowBlank = true;//分值A
            baoc_1.hide();
            tjxx1.hide();
            chongz1.hide();
            guanb1.hide();
            baoc_.show();
            tjxx.show();
            chongz.show();
            guanb.show();
            dxszx.show();
        	wzx.show();
        	//wzx.checked();
        }
        else 
            /*if (code == "QETT02") {//判断
                	if(wordNum){
                		wordNum.allowBlank = true;
                		wordNum.hide();
                	}
                	if(isLimitNum){
                		isLimitNum.hide();
                	}
                	if(wordNum2){
                		wordNum2.hide();
                	}
//					_c.setVisible(false);
//                    _m.reset();
                    _m.singleModel = false;
                    this.judegModel();
//                    Ext.each(_c.items.items, function(item){
//                        item.reset();
//                    });
                    _c.hide();
                    //multiAnswer.show();
					win.setHeight(250);
					//Ext.getCmp("multiAnswer").allowBlank = false;
            		Ext.getCmp("itemContent0").allowBlank = false;
//					_c.setVisible(false);
                }else*/ if(code == "wendt"){
        		wordNum.show();
        		wordNum.allowBlank = true;
        		isLimitNum.show();
        		wordNum2.show();
        		//Ext.getCmp("multiAnswer").allowBlank = true;
        		//选项A
        		Ext.getCmp("options0").allowBlank = true;
        		Ext.getCmp("options0").setDisabled(true);
        		Ext.getCmp("fzOptions0").allowBlank = true;//分值A
            	_m.singleModel = false;
            	//multiAnswer.hide();
            	_c.hide();
                _f.hide();
            	win.setHeight(300);
            	
            	dxszx.hide();
            	wzx.hide();
            	baoc_1.hide();
                tjxx1.hide();
                chongz1.hide();
                guanb1.hide();
                baoc_.hide();
                tjxx.hide();
                chongz.hide();
                guanb.hide();
            }
    },
    
    /**
     * 初始话预修改试题数据
     * @param {json} data
     */
    pushData: function(data){
        var temc = data.optionList;
        for (var i = 0, lan = temc.length; i < lan; i++) {
            //var item = this.down("#ans" + i).enable();
            var tmct = this.down("#tcID").down("#options" + i);
            tmct.enable();
            tmct.setValue(temc[i].optionName)
            tmct.allowBlank = false;
            tmct.focus();
        }
        
    },
    
    /**
     * 试题显示参考答案模式：判断题模式
     */
    /*
    judegModel: function(){
        this.down("#tcID").down("#itemContent0").allowBlank = true;
        var g = this.down("checkboxgroup");
        for (var i = 0; i < 6; i++) {
            var item = g.down("#ans" + i);
            //if (i > 1) {
		    item.hide();
            //}
            //else 
                if (i == 0) {
                    //item.boxLabelEl.setHTML("对");
                    item.enable();
					item.show();
                }
                else 
                    if (i == 1) {
                        //item.boxLabelEl.setHTML("错");
                        item.enable();
						item.show();
                    }
        }
    },*/
    
    /**
     *  试题显示参考答案模式：选择题模式
     */
    /*
    selectModel: function(){
        this.down("#tcID").down("#itemContent0").allowBlank = false;
        var g = this.down("checkboxgroup");
        for (var i = 0, x = 1; i < 6; i++, x++) {
            var item = g.down("#ans" + i);
            if (i > 1) {
                item.show().disable();
            }
            else 
                if (i == 0) {
                    item.boxLabelEl.setHTML("A");
                }
                else 
                    if (i == 1) {
                        item.boxLabelEl.setHTML("B");
                        item.disable();
                    }
        };
            },*/
    
    /**
     * 清空试题选项内容
     */
    clearTemContent: function(){
        for (var i = 1; i < 4; i++) {
            var tmct = this.down("#tcID").down("#options" + i);
            tmct.allowBlank = false;
            tmct.disable();
        }
    }
});
